package com.etc.hbase;



import com.google.common.base.Charsets;
import org.I0Itec.zkclient.exception.ZkMarshallingError;
import org.I0Itec.zkclient.serialize.ZkSerializer;



/**
 * @author 杰哥
 * @Title: MyZkSerializer
 * @ProjectName scalaworldcount
 * @Description: TODO
 * @date 2019/8/1915:40
 */
public class MyZkSerializer implements ZkSerializer {
    /**
     * 序列化，將物件轉化為位元組陣列
     */
    public byte[] serialize(Object obj) throws ZkMarshallingError {
        return String.valueOf(obj).getBytes(Charsets.UTF_8);
    }

    /**
     * 反序列化，將位元組陣列轉化為UTF_8字串
     */
    public Object deserialize(byte[] bytes) throws ZkMarshallingError {
        return new String(bytes, Charsets.UTF_8);
    }
}
